<template>
	<view class="container">
		<sort-search ></sort-search>
		<!-- 左侧滚动视图 -->
		<view class="scroll">
			<view  class="left">
				<uni-list>
					<uni-list-item title="健身补给" clickable @click="onClick(1)"></uni-list-item>
					<uni-list-item title="力量器材" clickable @click="onClick(2)"></uni-list-item>
					<uni-list-item title="有氧器械" clickable @click="onClick(3)"></uni-list-item>
					<uni-list-item title="男士服饰" clickable @click="onClick(4)"></uni-list-item>
					<uni-list-item title="女士服饰" clickable @click="onClick(5)"></uni-list-item>
				</uni-list>
			</view>
			<!-- 右侧滚动视图 -->
			<scroll-view scroll-y class="right">
				<view class="grid">
					<uni-grid :column="2" :showBorder="false" :highlight="false"  >

							<uni-grid-item v-for="(s,i) in res" :key="i"  >
								<view class="grid-ss" @click="goproducts(s.lid)">
								<image :src="$base+s.pic" mode="widthFix"></image>
								<text>{{s.title}}</text>
								</view>
							</uni-grid-item>
					</uni-grid>
				</view>
				<!-- 				<uni-card >
					<image src="../../static/sort/补给/com655457-1.jpg" mode="widthFix"></image>
					<text>蛋白棒</text>
				</uni-card> -->
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {productcategory} from '@/service/index.js'
	export default {
		data() {
			return {
            res:''
			}
		},
		async onLoad() {
			let res=await productcategory(1)
			console.log(res)
			this.res=res.result 
		},
		
		methods: {
			goproducts(e){
				uni.navigateTo({
					url:'/pages/productDetails/productDetails?lid='+e
				})
			},
					
async onClick(id) {
	console.log(id);
	let res=await productcategory(id)
	console.log(res)
	this.res=res.result
	
   }
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;

		.container {
			.scroll {
				display: flex;
				height: 100%;
				.left {
					position: fixed;
					z-index: 999;
					margin: 50px 0;
					width: 6.0rem;
					height: 80%;
					text-align: center;
					background-color: #fff;
				}
				.right {
					margin: 50px 0 50px 6.0rem;
					flex: 1;
					width: 100%;
					.grid{
						
						
						.grid-ss{
							margin: 5rpx;
							display: flex;
							flex-direction: column;
							image{
								width: 80%;
								margin: 0 auto;
							}
							text{
								text-align: center;
								font-size: 12px;
							}
							}
						
					}
				}
			}
		}
	}
</style>
